#!/bin/bash -e

if test -z $1; then echo `basename $0` fastqc.zip ...; fi

out_prefix=1

pngs='per_base_quality.png per_tile_quality.png per_sequence_quality.png per_base_sequence_content.png sequence_length_distribution.png duplication_levels.png adapter_content.png per_base_n_content.png'



for filez; do

echo $filez

dir0=`basename $filez .zip`

images=`junct_dir_file.pl $dir0/Images $pngs`
# unzip -o $filez $dir0/fastqc_data.txt
unzip -o $filez

head $dir0/fastqc_data.txt |perl -ne 'if(/^(Filename|Total|Sequence length)/){print}' |sed -e 's/\t/,/g' |csv2xls.pl - reads.summary.$dir0.xls


/mnt/ilustre/app/meta/bin/convert $images reads.summary.$dir0.pdf

rm -r $filez
done
